﻿/*

The MIT License

Copyright (c) 2010 Cartesian Analytics, Inc. 

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

namespace Pipra.Math
{
    /// <summary>
    /// A range which encompasses all values between two values, inclusive.
    /// </summary>
    /// <typeparam name="TValue">The value type.</typeparam>
    /// <remarks>
    /// A range where the high and low values are equal is a range that covers only one value.
    /// </remarks>
    public interface IRange<TValue> :
        IHasMagnitude<TValue>,
        IHasDistance<TValue, IRange<TValue>>,
        IHasDistance<TValue, TValue>,
        IIntersectable<TValue>,
        IIntersectable<IRange<TValue>>,
        IContainable<TValue>,
        IContainable<IRange<TValue>>,
        ITouches<TValue>,
        ITouches<IRange<TValue>>,
        IOverlappable<TValue>,
        IOverlappable<IRange<TValue>>,
        ICanBeDisjoint<TValue>,
        ICanBeDisjoint<IRange<TValue>>,
        ICanContain<TValue>,
        ICanContain<IRange<TValue>>,
        ICanCross<TValue>,
        ICanCross<IRange<TValue>>,
        System.IEquatable<TValue>,
        System.IEquatable<IRange<TValue>>
    {
        /// <summary>
        /// The lowest value of the range.
        /// </summary>
        TValue Low { get; }
        /// <summary>
        /// The highest value of the range.
        /// </summary>
        TValue High { get; }
        /// <summary>
        /// The average of the lowest and highest value.
        /// </summary>
        TValue Mid { get; }
        /// <summary>
        /// Creates a new range encompassing this range and the given <paramref name="value"/>.
        /// </summary>
        /// <param name="value">A value.</param>
        /// <returns>A range.</returns>
        IRange<TValue> Union(TValue value);
        /// <summary>
        /// Creates a new range encompassing this range and the given <paramref name="range"/>.
        /// </summary>
        /// <param name="range">A range.</param>
        /// <returns>A range.</returns>
        IRange<TValue> Union(IRange<TValue> range);
        /// <summary>
        /// Gets a copy of the range at the same center point but a scaled size.
        /// </summary>
        /// <param name="scale">The scaling factor.</param>
        /// <returns>A range.</returns>
        IRange<TValue> GetScaled(TValue scale);
        /// <summary>
        /// Gets a copy of the range at the same center point but with the given size.
        /// </summary>
        /// <param name="size">The size.</param>
        /// <returns>A range.</returns>
        IRange<TValue> GetResized(TValue size);
        /// <summary>
        /// Gets a copy of the range at the given <paramref name="center"/> point but with the same size.
        /// </summary>
        /// <param name="center">The center location.</param>
        /// <returns>A range.</returns>
        IRange<TValue> GetCentered(TValue center);
    }
}
